package com.qianyu.project.service.wh;

import com.qianyu.project.mapper.provider.wh.QualityDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class QualityServiceImpl implements QualityService {
    @Autowired
    QualityDao qualityDao ;

    @Override
    public List<Map<String, Object>> getList(@RequestParam Map<String,Object> m) {
        return qualityDao.GetList(m);
    }

    @Override
    public void del(String personnel) {
        qualityDao.del(personnel);
    }

    @Override
    public List<Map<String, Object>> getUser() {
        return qualityDao.getUser();
    }

    @Override
    public List<Map<String, Object>> getname() {
        return qualityDao.getname();
    }

    @Override
    public void add(Map<String, Object> m) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        String date = sdf.format(new Date());
        String date1 = date.replace("-", "");
        String date2 = qualityDao.getDate(date1);
        if (date2==null){
            date1=date1+"0001";
        }else{
            Integer integer = Integer.valueOf(date2);
            date1=integer+1+"";
        }
        m.put("id",date1);
        System.out.println(m);
        qualityDao.add(m);
    }
    @Override
    public void add2(Map<String, Object> m) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        String date = sdf.format(new Date());
        String date1 = date.replace("-", "");
        String date2 = qualityDao.getDate1(date1);
        if (date2==null){
            date1=date1+"0001";
        }else{
            Integer integer = Integer.valueOf(date2);
            date1=integer+1+"";
        }
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        String time1 = sdf1.format(new Date());
        m.put("id",date1);
        m.put("time1",time1);
        System.out.println(m);
        qualityDao.add2(m);
    }
    @Override
    public List<Map<String, Object>> getAbarbeitung(Map<String, Object> m) {
        return qualityDao.getAbarbeitung(m);
    }

    @Override
    public void delete(String personnel) {
         qualityDao.delete(personnel);
    }

    @Override
    public List<Map<String, Object>> getUserName() {
        return qualityDao.getUserName();
    }


}
